package vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.policies;

import java.util.Iterator;

import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;

import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.CommandDestinationsCreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.CommandDestinationsReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationContainerRelationshipCreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationContainerRelationshipReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship10CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship10ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship11CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship11ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship2CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship2ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship3CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship3ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship4CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship4ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship5CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship5ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship6CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship6ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship7CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship7ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship8CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship8ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship9CreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationship9ReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationshipCreateCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.commands.PresentationTemporalRelationshipReorientCommand;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.AbstractPresentationUIComponentCompartmentEditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.AbstractUIComponent2EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.CommandDestinationsEditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationContainerRelationshipEditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship10EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship11EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship2EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship3EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship4EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship5EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship6EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship7EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship8EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationship9EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.PresentationTemporalRelationshipEditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UIContainerRelationshipEditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship10EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship11EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship2EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship3EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship4EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship5EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship6EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship7EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship8EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationship9EditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.edit.parts.UITemporalRelationshipEditPart;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.part.AdaptedauiVisualIDRegistry;
import vn.edu.hcmus.fit.se.mdd.mbuid.adaptedaui.diagram.providers.AdaptedauiElementTypes;

/**
 * @generated
 */
public class AbstractPresentationItemSemanticEditPolicy extends
		AdaptedauiBaseItemSemanticEditPolicy {

	/**
	 * @generated
	 */
	public AbstractPresentationItemSemanticEditPolicy() {
		super(AdaptedauiElementTypes.AbstractPresentation_2002);
	}

	/**
	 * @generated
	 */
	protected Command getDestroyElementCommand(DestroyElementRequest req) {
		View view = (View) getHost().getModel();
		CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
				getEditingDomain(), null);
		cmd.setTransactionNestingEnabled(false);
		for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
			Edge incomingLink = (Edge) it.next();
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationContainerRelationshipEditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == CommandDestinationsEditPart.VISUAL_ID) {
				DestroyReferenceRequest r = new DestroyReferenceRequest(
						incomingLink.getSource().getElement(), null,
						incomingLink.getTarget().getElement(), false);
				cmd.add(new DestroyReferenceCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationshipEditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship2EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship3EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship4EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship5EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship6EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship7EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship8EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship9EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship10EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(incomingLink) == PresentationTemporalRelationship11EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						incomingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
				continue;
			}
		}
		for (Iterator<?> it = view.getSourceEdges().iterator(); it.hasNext();) {
			Edge outgoingLink = (Edge) it.next();
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationContainerRelationshipEditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationshipEditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship2EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship3EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship4EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship5EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship6EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship7EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship8EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship9EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship10EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
			if (AdaptedauiVisualIDRegistry.getVisualID(outgoingLink) == PresentationTemporalRelationship11EditPart.VISUAL_ID) {
				DestroyElementRequest r = new DestroyElementRequest(
						outgoingLink.getElement(), false);
				cmd.add(new DestroyElementCommand(r));
				cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
				continue;
			}
		}
		EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
		if (annotation == null) {
			// there are indirectly referenced children, need extra commands: false
			addDestroyChildNodesCommand(cmd);
			addDestroyShortcutsCommand(cmd, view);
			// delete host element
			cmd.add(new DestroyElementCommand(req));
		} else {
			cmd.add(new DeleteCommand(getEditingDomain(), view));
		}
		return getGEFWrapper(cmd.reduce());
	}

	/**
	 * @generated
	 */
	private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
		View view = (View) getHost().getModel();
		for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
			Node node = (Node) nit.next();
			switch (AdaptedauiVisualIDRegistry.getVisualID(node)) {
			case AbstractPresentationUIComponentCompartmentEditPart.VISUAL_ID:
				for (Iterator<?> cit = node.getChildren().iterator(); cit
						.hasNext();) {
					Node cnode = (Node) cit.next();
					switch (AdaptedauiVisualIDRegistry.getVisualID(cnode)) {
					case AbstractUIComponent2EditPart.VISUAL_ID:
						for (Iterator<?> it = cnode.getTargetEdges().iterator(); it
								.hasNext();) {
							Edge incomingLink = (Edge) it.next();
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationshipEditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship2EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship3EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship4EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship5EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship6EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship7EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship8EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship9EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship10EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UITemporalRelationship11EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(incomingLink) == UIContainerRelationshipEditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										incomingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										incomingLink));
								continue;
							}
						}
						for (Iterator<?> it = cnode.getSourceEdges().iterator(); it
								.hasNext();) {
							Edge outgoingLink = (Edge) it.next();
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationshipEditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship2EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship3EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship4EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship5EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship6EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship7EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship8EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship9EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship10EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UITemporalRelationship11EditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
							if (AdaptedauiVisualIDRegistry
									.getVisualID(outgoingLink) == UIContainerRelationshipEditPart.VISUAL_ID) {
								DestroyElementRequest r = new DestroyElementRequest(
										outgoingLink.getElement(), false);
								cmd.add(new DestroyElementCommand(r));
								cmd.add(new DeleteCommand(getEditingDomain(),
										outgoingLink));
								continue;
							}
						}
						cmd.add(new DestroyElementCommand(
								new DestroyElementRequest(getEditingDomain(),
										cnode.getElement(), false))); // directlyOwned: true
						// don't need explicit deletion of cnode as parent's view deletion would clean child views as well 
						// cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
						break;
					}
				}
				break;
			}
		}
	}

	/**
	 * @generated
	 */
	protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
		Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req)
				: getCompleteCreateRelationshipCommand(req);
		return command != null ? command : super
				.getCreateRelationshipCommand(req);
	}

	/**
	 * @generated
	 */
	protected Command getStartCreateRelationshipCommand(
			CreateRelationshipRequest req) {
		if (AdaptedauiElementTypes.PresentationContainerRelationship_4013 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationContainerRelationshipCreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.CommandDestinations_4014 == req
				.getElementType()) {
			return null;
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4015 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationshipCreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4016 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship2CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4017 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship3CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4018 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship4CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4019 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship5CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4020 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship6CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4021 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship7CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4022 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship8CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4023 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship9CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4024 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship10CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4025 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship11CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		return null;
	}

	/**
	 * @generated
	 */
	protected Command getCompleteCreateRelationshipCommand(
			CreateRelationshipRequest req) {
		if (AdaptedauiElementTypes.PresentationContainerRelationship_4013 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationContainerRelationshipCreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.CommandDestinations_4014 == req
				.getElementType()) {
			return getGEFWrapper(new CommandDestinationsCreateCommand(req,
					req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4015 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationshipCreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4016 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship2CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4017 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship3CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4018 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship4CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4019 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship5CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4020 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship6CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4021 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship7CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4022 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship8CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4023 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship9CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4024 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship10CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		if (AdaptedauiElementTypes.PresentationTemporalRelationship_4025 == req
				.getElementType()) {
			return getGEFWrapper(new PresentationTemporalRelationship11CreateCommand(
					req, req.getSource(), req.getTarget()));
		}
		return null;
	}

	/**
	 * Returns command to reorient EClass based link. New link target or source
	 * should be the domain model element associated with this node.
	 * 
	 * @generated
	 */
	protected Command getReorientRelationshipCommand(
			ReorientRelationshipRequest req) {
		switch (getVisualID(req)) {
		case PresentationContainerRelationshipEditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationContainerRelationshipReorientCommand(
					req));
		case PresentationTemporalRelationshipEditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationshipReorientCommand(
					req));
		case PresentationTemporalRelationship2EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship2ReorientCommand(
					req));
		case PresentationTemporalRelationship3EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship3ReorientCommand(
					req));
		case PresentationTemporalRelationship4EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship4ReorientCommand(
					req));
		case PresentationTemporalRelationship5EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship5ReorientCommand(
					req));
		case PresentationTemporalRelationship6EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship6ReorientCommand(
					req));
		case PresentationTemporalRelationship7EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship7ReorientCommand(
					req));
		case PresentationTemporalRelationship8EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship8ReorientCommand(
					req));
		case PresentationTemporalRelationship9EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship9ReorientCommand(
					req));
		case PresentationTemporalRelationship10EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship10ReorientCommand(
					req));
		case PresentationTemporalRelationship11EditPart.VISUAL_ID:
			return getGEFWrapper(new PresentationTemporalRelationship11ReorientCommand(
					req));
		}
		return super.getReorientRelationshipCommand(req);
	}

	/**
	 * Returns command to reorient EReference based link. New link target or source
	 * should be the domain model element associated with this node.
	 * 
	 * @generated
	 */
	protected Command getReorientReferenceRelationshipCommand(
			ReorientReferenceRelationshipRequest req) {
		switch (getVisualID(req)) {
		case CommandDestinationsEditPart.VISUAL_ID:
			return getGEFWrapper(new CommandDestinationsReorientCommand(req));
		}
		return super.getReorientReferenceRelationshipCommand(req);
	}

}
